﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using NetCoreCMS.Common;
using NetCoreCMS.IServices;

namespace NetCoreCMS.Web.Areas.Web.Controllers
{
    public class VideoController : BaseController
    {
        public ILiveService _live { get; set; }
        public int page = 1;         //当前页码
        public int totalcount = 0;   //OUT数据总数
        [ResponseCache(Duration = 600)]
        public IActionResult Index()
        {
            int.TryParse(Request.Query["page"], out page);
            page = page > 0 ? page : 1;
            ViewBag.Page = page;
            string strwhere = "where status=0 " ;
            var list = _live.GetList(page, 50, strwhere, "sort_id desc,id desc");
            totalcount = _live.RecordCount(strwhere);
            string pageUrl = Utils.CombUrlTxt("/Web/Live/Index", "page={0}", "__id__");
            ViewBag.pagelist = Utils.OutPageList(50, page, totalcount, pageUrl, 8);
            return View(list);
        }
        public IActionResult Show(int id)
        {
            var user = GetUserInfo();
            string username = "U"+Utils.GetRamCode();
            if (user != null)
                username = user.user_name;
            ViewBag.username = username;
            var model = _live.GetModel(id);
            ViewData["model"] = model;
            return View(model);
        }
    }
}